﻿/*
 * Created by SharpDevelop.
 * User: Carlos
 * Date: 01/06/2009
 * Time: 06:25 p.m.
 */
namespace Lambda.Data.NetQuery
{
    /// <summary>
    /// DbFunction. Representa una función de base de datos
    /// </summary>
    public abstract class BaseDbFunction : BaseCondition
    {
        #region Properties
            public virtual DbFunctionTypes Type{
                get { return DbFunctionTypes.StaticFunctions; }
            }
            public virtual ReturnValueTypes ReturnType{
                get { return ReturnValueTypes.Scalar; }
            }
        #endregion
        #region Interface Implementation
            public new virtual ConditionTypes ConditionType{
                get { return ConditionTypes.Single; }
            }
        #endregion
    }
    /// <summary>
    /// SingleFieldEvaluationFunction . Clase base para toda función de 
    /// evaluación de un solo campo
    /// </summary>
    public abstract class BaseSingleFieldEvaluationFunction : BaseDbFunction
    {
        #region Fields && Properties
            private BaseConditionElement field;
            public BaseConditionElement Field
            {
                get { return field; }
                set { field = value; }
            }
        #endregion
        #region Constructors
            public BaseSingleFieldEvaluationFunction(BaseConditionElement Field) {
                field = Field;
            }
        #endregion
    }
    /// <summary>
    /// IsNullFunction. Representa la función "es nulo"s
    /// </summary>
    public class IsNullFunction : BaseSingleFieldEvaluationFunction
    {
        #region Constructors
            public IsNullFunction(BaseConditionElement Field) : base(Field){}
        #endregion
    }
    /// <summary>
    /// IsNotNullFunction. Representa la función "no es nullo"
    /// </summary>
    public class IsNotNullFunction : BaseSingleFieldEvaluationFunction
    {
        #region Constructors
            public IsNotNullFunction(BaseConditionElement Field) : base(Field){}
        #endregion        
    }
    /// <summary>
    /// GetCurrentDateFunction. Representa la función "obtener fecha actual"
    /// </summary>
    public class GetCurrentDateFunction : BaseDbFunction, IFieldRelationElement
    {
        #region Base Implementation
            public override DbFunctionTypes Type{
                get{
                    return DbFunctionTypes.SystemFunctions;
                }
            }
        #endregion
        #region Interface Implementation
            public FieldRelationElementTypes FieldRelationElementType{
                get { return FieldRelationElementTypes.Function; }
            }
        #endregion
    }
}